package com.chinasoft.mall.model;

import java.util.ArrayList;
import java.util.List;

import com.chinasoft.mall.util.StringUtil;
import com.chinasoft.mall.util.SystemSetting;
import com.chinasoft.mall.widget.NetImageView;
import com.chinasoft.mall.widget.NetImageView.ImageViewCallback;

/**
 * 下载对象
 * 
 * @author Administrator
 * 
 */
public class DownloadInfo {
	// 下载状态 0 未下载完成1 下载完成
	private int downloadstate = 0;
	// 本地保存路径
	// private String localpath = "/data/cache/";
	// private String localpath = Environment.getExternalStorageDirectory()
	// + "/PalmarWorld/";
	private String localpath = SystemSetting.getDownloadFilePath();
	// 下载链接
	private String downloadurl = "";

	private List<NetImageView> nivs;
	// 图片宽
	private int wide;
	// 图片高
	private int height;
	// 是否需要立体圆角效果
	private boolean isCricle = false;
	// 是否影音
	private boolean isShadow = false;

	// 临时存储时间
	private String tempTime="";

	public String getTempTime() {
		return tempTime;
	}

	public void setTempTime(String tempTime) {
		this.tempTime = tempTime;
	}

	private NetImageView.ImageViewCallback imageCallback;

	public NetImageView.ImageViewCallback getImageCallback() {
		return imageCallback;
	}

	public void setImageCallback(NetImageView.ImageViewCallback imageCallback) {
		this.imageCallback = imageCallback;
	}

	public boolean isShadow() {
		return isShadow;
	}

	public void setShadow(boolean isShadow) {
		this.isShadow = isShadow;
	}

	public boolean isIsCricle() {
		return isCricle;
	}

	public void setIsCricle(boolean isCricle) {
		this.isCricle = isCricle;
	}

	public DownloadInfo(String downloadurl, NetImageView niv, boolean isshadow) {
		localpath += StringUtil.urlToFileName(downloadurl);
		this.isCricle = isshadow;
		this.downloadurl = downloadurl;
		nivs = new ArrayList<NetImageView>(1);
		nivs.add(niv);
	}

	public DownloadInfo(String downloadurl, NetImageView niv, boolean isshadow,
			ImageViewCallback imvb) {
		localpath += StringUtil.urlToFileName(downloadurl);
		this.isCricle = isshadow;
		this.downloadurl = downloadurl;
		nivs = new ArrayList<NetImageView>(1);
		nivs.add(niv);
		this.imageCallback = imvb;
	}

	// 设置图片的宽高
	public void setBitmapWH(int wide, int height) {
		this.wide = wide;
		this.height = height;
	}

	public int getWide() {
		return wide;
	}

	public int getHeight() {
		return height;
	}

	public int getDownloadstate() {
		return downloadstate;
	}

	public String getLocalpath() {
		return localpath;
	}

	public String getDownloadurl() {
		return downloadurl;
	}

	public List<NetImageView> getNivs() {
		return nivs;
	}

	public void setDownloadstate(int downloadstate) {
		this.downloadstate = downloadstate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((downloadurl == null) ? 0 : downloadurl.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DownloadInfo other = (DownloadInfo) obj;
		if (downloadurl == null) {
			if (other.downloadurl != null)
				return false;
		} else if (!downloadurl.equals(other.downloadurl))
			return false;
		return true;
	}
}
